<?php
date_default_timezone_set('prc');
header ( 'content-type:text/html; charset=utf-8' );
session_start ();
@$yu=$_REQUEST['yu'];
@$card=$_REQUEST['card'];
@$fu=$_REQUEST['fu'];


$pdo=new PDO('mysql:dbname=can;charset=utf8','root');

$s=$pdo->prepare('select * from yu');
$s->execute(array());
$y=$s->fetch(PDO::FETCH_NAMED);

$q=$y['yu']-$yu;


$s=$pdo->prepare('select * from ka where id=:card');
$s->execute(array('card'=>$card));
$k=$s->fetch(PDO::FETCH_NAMED);

$a=$k['rmb']+$yu;


if ($fu!=$y['fu']){
	header('content-type:text/html; charset=utf-8');
	header('Refresh:3;url=/yu.php');
	echo "支付密码错误,3秒后返回提现页面。";
}else {
	if ($yu>$y['yu']){
		header('content-type:text/html; charset=utf-8');
		header('Refresh:3;url=/yu.php');
		echo "对不起，余额不足，无法提现。";
	}else {
		$s=$pdo->prepare('update ka set rmb=:rm where id=:card');
		if($s->execute(array('card'=>$card,'rm'=>$a))){
			header('content-type:text/html; charset=utf-8');
			header('Refresh:3;url=/yu.php');
			$s=$pdo->prepare('update yu set yu=:yu where fu=:card');
			if ($s->execute(array('card'=>$y['fu'],'yu'=>$q))){
				$time=date('Y-m-d H:i:s');
				$s=$pdo->prepare('insert into jilu values(null,:jian,"-",:jin,2)');
				$s->execute(array('jian'=>$time,'jin'=>$yu));
				echo "提现成功";
			}
		}else {
			echo "error";
		}
		
	}
}